import 'package:flutter/material.dart';
import 'package:get/get.dart';

import '../src/generated/models/setting.pb.dart';
import '../tools/build.dart';
import '/constants.dart';
import '/controllers/main_screen_controller.dart';
import '/api/api.dart';
import '/locator.dart' as locator;
import 'home_screen.dart';
import 'components/layout/footer.dart';
import 'components/layout/header.dart';
import 'components/layout/side_menu.dart';

class MainScreen extends StatefulWidget {
  @override
  _MainScreenState createState() => _MainScreenState();

  static MaterialPageRoute routeRebuild(RouteSettings settings) {
    return MaterialPageRoute(
        settings: settings, builder: (context) => MainScreen());
  }
}

class _MainScreenState extends State<MainScreen> {
  final MainScreenController _ctl = Get.put(MainScreenController());

  Widget mainScreenBuilder() {
    return Scaffold(
      key: _ctl.scaffoldKey,
      drawer: SideMenu(),
      body: SingleChildScrollView(
        child: Column(
          children: [
            Header(),
            Container(
              padding: EdgeInsets.all(kDefaultPadding),
              constraints: BoxConstraints(maxWidth: kMaxWidth),
              child: SafeArea(child: HomeScreen()),
            ),
            Footer(),
          ],
        ),
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return mainScreenBuilder();
  }
}
